package org.tongdao.yulong.h_aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.stream.Stream;

/**
 * @Description: TODO
 * @author: 殷玉龙
 * @date: 2020年10月10日 3:58 下午
 */
public class AwaredTestBean implements ApplicationContextAware, BeanNameAware {

  private ApplicationContext ctx;
  private String beanName;

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    ctx = applicationContext;
  }

  public void printBeanNames(){
    Stream.of(ctx.getBeanDefinitionNames()).forEach(System.out::println);
  }

  @Override
  public void setBeanName(String s) {
    this.beanName = s;
  }

  public String getBeanName() {
    return beanName;
  }
}
